<if condition="!IS_AJAX">

<div style="margin:10px 0;"><a onClick="_openWindow('{:U('add',array('modules_id' => $modules_id,'fieldlist' => $fieldlist,'tablename' => $tablename))}', 500, '添加数据', '保存', function(){ $('#windowlistboxform').submit();}, 1);" href="##" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-plus"></i>添加数据</a></div>

<table class="table table-bordered" width="100%" border="0" cellpadding="0" cellspacing="0">
 <thead>
 <tr><td align="center" class="hidden-xs">ID</td>
 <volist name="fields" id="vo">
    <td align="center" <if condition="$vo['fieldname'] neq 'title' && $vo['fieldname'] neq 'sort'">class="hidden-xs"</if>>{$vo.remark}</td>
    </volist>
    
    <td align="center">操作</td>
  </tr>
</thead>
<tbody id="windowlistbox">

</if>
<if condition="IS_AJAX">


<volist name="list" id="vo">
  <tr class="data_list" id="windowlistbox-{$vo.id}">
  <td align="center" class="hidden-xs"><input type="checkbox" name="id" id="id" class="sall" value="{$vo.id}" />{$vo.id}</td>
  
  <volist name="fields" id="svo">
    <td <if condition="$svo['fieldname'] neq 'title' && $svo['fieldname'] neq 'sort'">class="hidden-xs"</if>><eq name="svo['type']" value="0"><div style="max-width:100px;"><span <if condition="$vo[$svo['fieldname']] eq ''">style="padding:0 5px; border:1px dashed #C3C3C3;"</if> class="ajaxText" tablename="{$svo['tablename']}" field="{$svo['fieldname']}" id="{$vo.id}" val="{$vo[$svo['fieldname']]}">{$vo[$svo['fieldname']]}</span></div></eq>
    <eq name="svo['type']" value="4"><if condition="$vo[$svo['fieldname']] neq ''"><img src="{:getThumbPath($vo[$svo['fieldname']])}" width="50" height="50"></if></eq>
    <eq name="svo['type']" value="5"><input name="sort" width="30" type="hidden" value="{$vo[$svo['fieldname']]}" size="4" /><a class="fl" href="javascript:void(0);" onclick="update_sortClick('id','up',this,'sort','{:U('dosort',array('modules_id' => $modules_id,'tablename' => $tablename))}');"><i class="glyphicon glyphicon-arrow-up"></i></a><a class="fr" href="javascript:void(0);" onclick="update_sortClick('id','',this,'sort','{:U('dosort',array('modules_id' => $modules_id,'tablename' => $tablename))}');"><i class="glyphicon glyphicon-arrow-down"></i></a></eq>
    </td>
    </volist>
         
    <td align="center"><a onClick="_openWindow('{:U('add',array('modules_id' => $modules_id, 'parent_id' => $vo['id'], 'fieldlist' => $fieldlist,'tablename' => $tablename))}', 500, '添加子级', '保存', function(){ $('#windowlistboxform').submit();}, 1);" class="btn btn-warning btn-xs" href="##">添加子级</a> <a class="btn btn-success btn-xs" href="##" onClick="_openWindow('{:U('edit',array('modules_id' => $modules_id,'map'=>'id,'.$vo['id'],'fieldlist' => $fieldlist,'tablename' => $tablename))}', 500, '编辑数据', '保存', function(){ $('#windowlistboxform').submit();}, 1);">编辑</a> <a class="btn btn-danger btn-xs deleteBtn" rel="{:U('delete',array('modules_id' => $modules_id,'id'=>$vo['id'],'tablename' => $tablename))}" data-id="{$vo.id}">删除</a></td>
  </tr>
  
  <volist name="vo['sub']" id="subvo">
             <tr class="data_list" id="windowlistbox-{$subvo.id}">
             <td align="center"  class="hidden-xs"><input type="checkbox" name="id" id="id" class="sall" value="{$subvo.id}" />{$subvo.id}</td>
                  <volist name="fields" id="ssvo">
    <td <if condition="$ssvo['fieldname'] neq 'title' && $ssvo['fieldname'] neq 'sort'">class="hidden-xs"</if> <eq name="key" value="0">style="text-indent:{$subvo['deep']*20}px"</eq>><eq name="ssvo['type']" value="0"><eq name="key" value="0"><gt name="subvo['deep']" value="0">∟</gt></eq>{$subvo[$ssvo['fieldname']]}</eq>
    <eq name="ssvo['type']" value="4"><img src="{:getThumbPath($subvo[$ssvo['fieldname']])}" width="50" height="50"></eq>
    <eq name="ssvo['type']" value="5"><input name="sort" width="30" type="hidden" value="{$subvo[$ssvo['fieldname']]}" size="4" /><a href="javascript:void(0);" onclick="update_sortClick('id','up',this,'sort','{:U('dosort',array('modules_id' => $modules_id,'tablename' => $tablename))}');"><i class="glyphicon glyphicon-arrow-up"></i></a><a href="javascript:void(0);" onclick="update_sortClick('id','',this,'sort','{:U('dosort',array('modules_id' => $modules_id,'tablename' => $tablename))}');"><i class="glyphicon glyphicon-arrow-down"></i></a></eq>
    </td>
    </volist> 
   
    <td align="center"><a onClick="_openWindow('{:U('add',array('modules_id' => $modules_id, 'parent_id' => $svo['id'], 'fieldlist' => $fieldlist,'tablename' => $tablename))}', 500, '添加子级', '保存', function(){ $('#windowlistboxform').submit();}, 1);" href="##" class="btn btn-warning btn-xs">添加子级</a> <a class="btn btn-success btn-xs" href="##" onClick="_openWindow('{:U('edit',array('parent_id' => $subvo['pid'],'modules_id' => $modules_id,'map'=>'id,'.$subvo['id'],'fieldlist' => $fieldlist,'tablename' => $tablename))}', 500, '编辑数据', '保存', function(){ $('#windowlistboxform').submit();}, 1);">编辑</a> <a rel="{:U('delete',array('modules_id' => $modules_id,'id'=>$subvo['id'],'tablename' => $tablename))}" class="btn btn-danger btn-xs deleteBtn" data-id="{$subvo.id}">删除</a></td>
    
     
             </tr>
        </volist>
  
</volist> 
</if>


<if condition="!IS_AJAX">
</tbody>

   </table> 
    
    
    
    
    
     <div class="windowlistboxpages">
        
      </div>
    <form action="{:U('', $_GET)}" id="windowlistboxform"></form>
    
    <script>
	     $('#windowlistbox').ajaxlist({loading:'<tr><td colspan="<php> echo count($fields)+1</php>"><div class="lockwindowlayout" id="lockwindowlayout" style="overflow:hidden; padding:10px 0;"><div class="loader-inner ball-beat" style="text-align:center;"><div></div><div></div><div></div><div></div><div></div></div><style>.lockwindowlayout .line-scale{height:20px;}.lockwindowlayout .ball-beat div{background:#ed5565;}</style></div></td></tr>',nodata:'<tr><td colspan="<php> echo count($fields)+1</php>" align="center">暂无数据</td></tr>'});
		 
		 //更新排序,点击移动更新
	function update_sortClick(key,type,el,field,sendurl){
		var data=new Array();
		if(type=='up'){
			$(el).parent().parent().after($(el).parent().parent().prev());
		}else{
			$(el).parent().parent().next().after($(el).parent().parent());
		}
		$("input[name='"+key+"']").each(function(index, element) {
			$(this).parent().parent().find("input[name='"+field+"']").val(index+1);
            data.push($(this).val()+'_'+$(this).parent().parent().find("input[name='"+field+"']").val());
        });
		
		//列新排序
		update_sort(key,field,el,sendurl);
	}
		 //key主键/field更新字段名/el当前按钮对象/url服务端地址
	function update_sort(key,field,el,url){
		var data=new Array();
		$("input[name='"+key+"']").each(function(index, element) {
            data.push($(this).val()+'_'+$(this).parent().parent().find("input[name='"+field+"']").val());
        });
		$.post(url,{
			'sort':data.toString(),
			'field':field, 'tablename': 
		    '{$tablename}'},function(data){
			if(data=='OK'){
				if(el==''){
					success('更新成功');
				}
			}else{
				error('更新失败');
			}
		});
	}
		 
		 function _openWindow(url, width, title, buttontitle, callback, source){
		
		
		$(window).unbind("scroll");

		
		var lock = true;
		var height = $(window).height() - 200;
		<if condition="isMobile()">
			width = '100%';
			lock = false;
			var height = $(window).height() - 45;
			</if>
		var mydialog = art.dialog.load(url, {button:[{
				
				  name: '不懂？点我！',
				  classname: "btn btn-sm btn-info data-introbtn",
				  callback: function () {
					  //引导教程
					  ///alert();
					  introJs('.aui_state_focus .aui_outer').setOptions({exitOnOverlayClick:false,prevLabel:'&larr; 上一步','nextLabel':'下一步 &rarr;','skipLabel':'跳过','doneLabel':'关闭'}).start();
					  
					  return false;
				  },
				  focus: false
			  
			}],init:function(){
			//打开窗口后隐藏其它不必要元素
			
			//alert($('.aui_content').html());
			
			
			
			
			
			
			
			
			
			
			
			
			//return false;
			<if condition="isMobile()">
			$('#lockwindowlayout').remove();
			//$(".auii_statei_focus").hide();
			
			$('.modal-shiftfix').addClass('hidden');
			$('body').addClass('padding0');
			$('.aui_state_focus').addClass('auii_statei_focus');
						
			
			
			
			
			
			
			
			$.cookie("scroll_hidden",$(document).scrollTop())
			
			//隐藏底层
			$(".sticky-header > section").hide();
			
			$(".sticky-header").css({height:($(window).height())+'px'});
			//$("html").css({overflow:'hidden'});
			$("html").addClass('scroll_hidden');
			$("html").getNiceScroll().remove();
			

			
			$(mydialog.DOM.outer[0]).find('.aui_titleBar button').each(function(index, element) {
                $(this).click(function(e) {
                    $(mydialog.DOM.outer[0]).find('.aui_buttons button').eq(index).trigger('click');
                });
            });
			
				$(mydialog.DOM.outer[0]).find('.aui_main').height($(window).height() - 90);
			
			 <else/>
			 
			 
			 
			 $('.aui_state_focus').addClass('auii_statei_focus');
			 
			 
			if($(mydialog.DOM.outer[0]).find('.aui_main').height() > $(window).height() - 100){
				$(mydialog.DOM.outer[0]).find('.aui_main').height($(window).height() - 200);
				
				
				
			}
			
			
			$.cookie("scroll_hidden",$(document).scrollTop())
			$(".sticky-header").css({overflow:'hidden', height:($(window).height())+'px'});
			//$("html").css({overflow:'hidden'});
			 $("html").addClass('scroll_hidden');
			$("html").getNiceScroll().remove();
			

			
			
			
			
			mydialog._reset();
			
			
			</if>
			if($(mydialog.DOM.outer[0]).find("[data-intro]").length == 0){
				 
						$(mydialog.DOM.outer[0]).find(".data-introbtn").remove();
					}
			
			var niceScroll = $(mydialog.DOM.outer[0]).find(".aui_main").niceScroll({scrollspeed:20,styler:"fb",cursorcolor:"#65cea7", cursorwidth: '3', cursorborderradius: '0px', background: '#424f63', spacebarenabled:false, cursorborder: '0'});
				
				$(mydialog.DOM.outer[0]).find(".aui_main").click(function(e) {
					$('#'+niceScroll.id).css('z-index', $('#'+niceScroll.id).css('z-index')*1+2);
                });
				
			
			
			var index = $(".auii_statei_focus").length;
			index ++;
			
			$(".aui_state_focus").attr("index", index);
			$(".aui_state_focus").attr('rel', url);
			$('.aui_state_focus').addClass('index'+index);
			
			
			
			
			if(buttontitle == 'button'){
				 $(mydialog.DOM.outer[0]).find('.aui_titleBar button').html($('.auii_statei_focus .OptionBtn').html());
			 }if(title == ''){
				 $(mydialog.DOM.outer[0]).find('.aui_titleBar .aui_title').html($('.auii_statei_focus .OptionTitle').html());
			 }
			 
			 
	
			 $(mydialog.DOM.outer[0]).find(".checkoutform:eq(0)").Validform({
							ajaxPost:true,
							tiptype:function(msg, s, data){
								if(s.type == 1){
									$.ThinkBox.success('正在处理，请稍等……',{'delayClose':500,modal:false, 'close': '关闭',x:0,y:0,center:false,locate:['left','top'], show:['',0]});
									
								}
								if(s.type == 3){
								$.ThinkBox.error(msg,{'delayClose':500,modal:false, 'close': '关闭',x:0,y:0,center:false,locate:['left','top'], show:['',0]});
							}
							},
							datatype:{
								"text":function(gets,obj,curform,regxp){
									return true;
								},"image":function(gets,obj,curform,regxp){
									return true;
								}
							},
							callback:function(data){
								//检测登录 
								$('.ThinkBox-close').trigger('click');
								if(data.status == 0){
									//$.ThinkBox.error(data.info,{'delayClose':200});
									//$.ThinkBox('hide');
									$.ThinkBox.error(data.info,{'delayClose':500,modal:false, 'close': '关闭',x:0,y:0,center:false,locate:['left','top'], show:['',0]});
									
								}else{
									//alert(data.info); 
									//alert(id);
									if(callback != null){
										callback();
									} 
									//更新列表
									mydialog.close();
								}
							}
						});
			 
		},width: width, height: 'auto',lock:lock,title:title,ok:function(){
			
			
			
			
			
			
			
			$(mydialog.DOM.outer[0]).find('.checkoutform:eq(0)').submit();
			
			
			if($(mydialog.DOM.outer[0]).find(".checkoutform").length > 0){
				return false;
			}else{if(callback != null){
				callback();
				mydialog.close(); 
				return false;

			}
			
			}
			
			
			
			
		},okVal:buttontitle,close:function(){
			$(mydialog.DOM.outer[0]).find(".aui_main").getNiceScroll().remove();
			//销毁百度编辑器class="ueditorelement"
			//alert($('.ueditorelement'));
			$('.ueditorelement').each(function(index, element) {
                UE.getEditor($(this).attr('id')).destroy(); 
            });
			
		
			
			if($(".auii_statei_focus").length > 1){
				$(".auii_statei_focus.index"+($(".aui_state_focus").attr("index")*1 - 1)).show().addClass("aui_state_focus");
			}else{
				
				$(".sticky-header").css({height:'auto'});
				$("html").niceScroll({styler:"fb",cursorcolor:"#65cea7", cursorwidth: '6', cursorborderradius: '0px', background: '#424f63', spacebarenabled:false, cursorborder: '0',  zindex: '1000'}); 
				
				$(".sticky-header > section").show();
				$("html").removeClass('scroll_hidden');
				$("html,body").animate({scrollTop:$.cookie("scroll_hidden")},100);
				$(".modal-shiftfix").removeClass("hidden");
				$("body").removeClass("padding0");
			}
			
			
			
		}});
	}
		 
	</script>
    
    
</if>